// PK进度条（带文字）
import QtQuick 2.15

Item {
    id: root
    
    property real value: 0
    property real minimum: 0
    property real maximum: 100
    property real progress: Math.max(0, Math.min(1, (value - minimum) / (maximum - minimum)))
    
    property color leftColor: "#2B4AFF"
    property color rightColor: "#FF0000"
    property string leftText: "十三先生"
    property string rightText: "对手"
    
    Rectangle {
        id: leftBar
        anchors.left: parent.left
        anchors.top: parent.top
        anchors.bottom: parent.bottom
        width: parent.width * progress
        color: leftColor
        
        Text {
            anchors.left: parent.left
            anchors.leftMargin: 20
            anchors.verticalCenter: parent.verticalCenter
            text: leftText
            color: "white"
            font.pixelSize: 12
        }
    }
    
    Rectangle {
        id: rightBar
        anchors.left: leftBar.right
        anchors.top: parent.top
        anchors.bottom: parent.bottom
        anchors.right: parent.right
        color: rightColor
        
        Text {
            // 像左侧文字一样，固定在rightBar的左侧固定位置
            anchors.left: parent.left
            anchors.leftMargin: 20  // 与左侧文字相同的边距
            anchors.verticalCenter: parent.verticalCenter
            text: rightText
            color: "white"
            font.pixelSize: 12
        }
    }
}

